<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改record')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-record-edit" th:object="${wxDriverRecord}">
        <input name="recordId" th:field="*{recordId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">项目名称：</label>
            <div class="col-sm-8">
                <input name="programName" th:field="*{programName}" class="form-control" type="text" readonly>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">供应商：</label>
            <div class="col-sm-8">
                <input name="supplierName" th:field="*{supplierName}" class="form-control" type="text" readonly>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">司机姓名：</label>
            <div class="col-sm-8">
                <input name="driverName" th:field="*{driverName}" class="form-control" type="text" readonly>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">打卡时间：</label>
            <div class="col-sm-8">
                <input name="driverName" th:field="*{createTimes}" class="form-control" type="text" readonly>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">材料员姓名：</label>
            <div class="col-sm-8">
                <input name="materName" th:field="*{materName}" class="form-control" type="text" readonly>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">工作内容：</label>
            <div class="col-sm-8">
                <select id="workContent" name="workContent" class="form-control">
                    <option th:each="contents : ${workContents}" th:text="${contents.dictLabel}"
                            th:value="${contents.dictLabel}"
                            th:selected="${wxDriverRecord.workContent == contents.dictLabel}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">装卸点名称：</label>
            <div class="col-sm-8">
                <select id="remark" name="remark" class="form-control">
                    <option th:each="mark : ${remarks}" th:text="${mark.lable}" th:value="${mark.lable}"
                            th:selected="${wxDriverRecord.remark == mark.lable}"></option>
                </select>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<script th:inline="javascript">
    var prefix = ctx + "system/record";
    $("#form-record-edit").validate({
        focusCleanup: true
    });

    $("#workContent").change(function () {
        workContent = $("#workContent").val();
        $.ajax({
            url: prefix + '/selectUnloadingByDictType?workContent=' + workContent,
            success: function (data) {
                $("#remark").empty();
                var option = "";
                for (var i in data) {
                    option += '<option value="' + data[i].lable + '">' + data[i].lable + '</option>'
                }
                $("#remark").append(option)
            }
        })

    });

    function submitHandler() {
        if ($.validate.form()) {
            if ($("#workContent").val() == '') {
                $.modal.alertWarning("请选择工作内容！");
                return;
            }
            if ($("#remark").val() == '') {
                $.modal.alertWarning("请选择装卸点名称！");
                return;
            }
            $.operate.save(prefix + "/edit", $('#form-record-edit').serialize());
        }
    }

</script>
</body>
</html>